<template>
  <div>
    <!-- 客户下拉菜单 -->
    <el-tooltip v-if="tabType === 'customer' && !newEmptySeat" class="item" effect="dark" :content="$t('customer.newCustomer')" placement="bottom">
      <i class="iconfont icon-xinjiankehu fontResize" style="width: 16px;font-size: 16px;padding-right:4px;cursor:pointer;" @click.stop="addNewCust"></i>
    </el-tooltip>
    <el-dropdown class="rel-operation" trigger="click" @command="custNav" v-if="tabType === 'customer'" size="small">
      <span class="el-dropdown-link">
         <el-tooltip class="item" effect="dark" :content="$t('public.moreOper')" placement="bottom">
           <i class="iconfont icon-gengduo fontResize"></i>
         </el-tooltip>
      </span>
      <el-dropdown-menu slot="dropdown" v-if="!newEmptySeat">
        <el-dropdown-item class="ro-dropdown" v-show="isNotAllowEditCustomerInfo && isAllowMergeCustomer" command="/index/customer/merge">{{$t('public.merge')}}</el-dropdown-item>
        <el-dropdown-item class="ro-dropdown" command="/index/customer/customize">{{$t('customer.CustomerSearch.CustomizeFastSearch')}}</el-dropdown-item>
        <el-dropdown-item class="ro-dropdown" command="/index/customer/export">{{$t('customer.uploadTask')}}</el-dropdown-item>
        <el-dropdown-item class="ro-dropdown" command="/index/customer/listQuery">{{$t('customer.HitSingle')}}</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
    <!-- 在线咨询下拉菜单 -->
    <el-dropdown class="rel-operation" trigger="click" @command="webchatExport" v-if="tabType === 'webchat'" size="small">
      <span class="el-dropdown-link">
         <el-tooltip class="item" effect="dark" :content="$t('public.moreOper')" placement="bottom">
           <i class="iconfont icon-gengduo fontResize"></i>
         </el-tooltip>
      </span>
      <el-dropdown-menu slot="dropdown" v-if="!newEmptySeat">
        <el-dropdown-item class="ro-dropdown" command="exportChatRecord">{{$t('webchat.exportChatRecord')}}</el-dropdown-item>
        <el-dropdown-item class="ro-dropdown" command="exportChatContent">{{$t('webchat.exportChatContent')}}</el-dropdown-item>
        <el-dropdown-item class="ro-dropdown" command="exportRouter">{{$t('webchat.exportTaskList')}}</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
    <!-- 通话下拉菜单 -->
    <el-dropdown class="rel-operation"
                 trigger="click"
                 @command="custNav"
                 size="small"
                 v-if="tabType === 'call'">
      <span class="el-dropdown-link">
           <el-tooltip class="item" effect="dark" :content="$t('public.moreOper')" placement="bottom">
             <i class="iconfont icon-gengduo fontResize"></i>
           </el-tooltip>
      </span>
      <el-dropdown-menu slot="dropdown" v-if="!newEmptySeat">
        <el-dropdown-item class="ro-dropdown"
                          v-if="isCallLeakSheet"
                          command="/index/call/cdr_all/assginLeakSheetDetail">
            {{$t('routeI18n.misscall')}}</el-dropdown-item>
        <el-dropdown-item class="ro-dropdown"
                          v-if="isCallExport"
                          command="/index/call/cdr_all/callExport">
            {{$t('routeI18n.bacthExportTask')}}</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>

</template>
<script>
  import bus from '@/store/eventBus'
  import { isAllowMergeCustomer, isNotAllowEditCustomerInfo } from '@/utils/customerUtils.js'
  export default {
    name: 'DropdownMenu',
    props: {
      placeHolder: String,
      type: String,
      newEmptySeat: Boolean,
      tabType: String,
      isBatchExportRecordTask: Boolean,
      isCallLeakSheet: Boolean,
      isCallExport: Boolean
    },
    data () {
      return {
      }
    },
    computed: {
      isNotAllowEditCustomerInfo () {
        return !isNotAllowEditCustomerInfo(this.$store.state.session.user)
      },
      isAllowMergeCustomer () {
        return isAllowMergeCustomer(this.$store.state.session.user)
      }
    },
    methods: {
      custNav (command) {
        // if (command === '/index/customer/add') {
        //   bus.$emit('resetAddCustomer')
        //   this.$router.push(command)
        // } else {
          this.$router.push(command)
        // }
      },
      webchatExport (command) {
        if (command === 'exportRouter') {
          this.$router.push('/index/webchat/webchat_all/export')
        } else if (command === 'exportChatRecord') {
          this.$emit('chatRecord')
        } else if (command === 'exportChatContent') {
          this.$emit('chatContent')
        }
      },
      addNewCust () {
        bus.$emit('resetAddCustomer')
        this.$router.push({path: '/index/customer/add'})
      },
    }
  }
</script>
<style lang="stylus" scoped>
@import "../../../../assets/common"
.rel-operation
  height 30px
  line-height 30px
  font-size 18px
  margin-right 6px
  flex 1
  cursor pointer
  :hover
    color $c-main !important
.ro-dropdown
  color $cf-level1
.el-icon-plus, .iconfont
  margin-right 3px
  color $c-main
  font-size 16px
.icon-zidingyikuaijiesousuo
  color $c-main
.icon-zidingyikuaijiesousuo
  color $c-main
.fontResize
  font-size 18px
</style>
